package com.autumn.juc.sync;

import org.openjdk.jol.info.ClassLayout;

/**
 * 关闭指针压缩：-XX:-UseCompressedOops
 */
public class ObjectTest {
    public static void main(String[] args) throws InterruptedException {
        //Thread.sleep(5000);
        Object obj = new Object();
        //Object obj = new Test();
        //Object obj = new Integer[4];
        //obj.hashCode();
        // 查看对象内部信息
        System.out.println(ClassLayout.parseInstance(obj).toPrintable());

        new Thread(() -> {
            synchronized (obj) {
                System.out.println(Thread.currentThread().getName() + "\n" + ClassLayout.parseInstance(obj).toPrintable());
            }
        }, "Thread1").start();
    }
}

class Test {
    private boolean flag;
    private long p;
}
